package org.csu.demo.db.service;

import org.csu.demo.db.domain.Teacher;
import org.csu.demo.db.persistence.TeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    public Optional<Teacher> getTeacherByName(String teacherName) {
        return teacherMapper.selectList(null).stream()
                .filter(teacher -> teacher.getTeachername().equals(teacherName))
                .findFirst();
    }
}
